from django.db import models
from libs.db import BaseModel
from connection.models import Connection


class TaskLog(BaseModel):
    connection = models.ForeignKey(Connection, related_name='task_logs', on_delete=models.CASCADE)
    date = models.DateField('日期')
    start_at = models.DateTimeField('开始时间')
    end_at = models.DateTimeField('结束时间')
    time_spent = models.IntegerField('耗时(ms)')
    success = models.BooleanField('执行成功', default=False)
    content = models.TextField('执行log')

    class Meta:
        verbose_name = '定时任务log'
        verbose_name_plural = '定时任务log'
        ordering = ('-id',)
